import view.LoginFrame;
import util.DatabaseInitializer;
import javax.swing.*;

/**
 * 自习室座位预约系统主程序入口
 */
public class Main {
    public static void main(String[] args) {
        // 设置系统外观
        try {
            for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception e) {
            // 使用默认外观
        }

        // 检查并初始化数据库
        if (DatabaseInitializer.needsInitialization()) {
            try {
                DatabaseInitializer.initDatabase();
            } catch (Exception ex) {
                System.err.println("数据库初始化失败: " + ex.getMessage());
            }
        }

        // 启动登录界面
        SwingUtilities.invokeLater(() -> {
            new LoginFrame().setVisible(true);
        });
    }
}